/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package controller;

import java.sql.*;
import oracle.jdbc.pool.OracleDataSource;

/**
 *
 * @author Satellite
 */
public class Proses {

//        String jdbcUrl = "jdbc:oracle:thin:@172.23.9.185:1521:orcl";
//    String userid = "MHS105314099";
//    String password = "MHS105314099";
    String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:xe";
    String userid = "hr";
    String password = "afterglow";
    Connection conn;
    Statement stmt;
    ResultSet rset;
    String query;
    String sqlString;

    public Proses() {
    }

    public Connection getDBConnection() {
        try {
            OracleDataSource ds;
            ds = new OracleDataSource();
            ds.setURL(jdbcUrl);
            conn = ds.getConnection(userid, password);
            System.out.println("Koneksi berhasil");

        } catch (SQLException ex) {
            System.out.println("Masih belum koneksi");
        }
        return conn;
    }

    public String isintablestaff(String staffid) throws SQLException {
        String query = "select email from penonton where email='" + staffid + "'";
//        String query = "select email from penonton";
        String hasil = null;
        getDBConnection();
        java.sql.Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
        ResultSet rz;
        rz = stmt.executeQuery(query);
        while (rz.next()) {
            hasil = (rz.getString(1));
        }
        return hasil;
    }

    public String isintablestaff1(String staffid) throws SQLException {
//        String query = "select PASSWORD from penonton";
        String query = "select PASSWORD from penonton where email='" + staffid + "'";
        String hasil = null;
        getDBConnection();
        java.sql.Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
        ResultSet rz;
        rz = stmt.executeQuery(query);
        while (rz.next()) {
            hasil = (rz.getString(1));
        }
        return hasil;
    }

}
